﻿@inherits AntDesignTestBase

@code {
    class Model
    {
        public string? ValidateField { get; set; }
    }
    Model _model = new();
    Form<Model>? form;
    FormItem? formItem;
    ValidationMessageStore? validationMessageStore;
   
    [Fact]
    public void Form_UpdateValidateMessage()
    {
        //Arrange
        JSInterop.Setup<AntDesign.JsInterop.Window>(JSInteropConstants.GetWindow)
    .SetResult(new AntDesign.JsInterop.Window());
        var cut = Render(
    @<Form Model="@_model" @ref="form">
        <FormItem @ref="formItem"> <AntDesign.Input @bind-Value=@_model.ValidateField /></FormItem>
        <FormItem >
            <Button Type="@ButtonType.Primary" HtmlType="submit">
                Submit
            </Button>
        </FormItem>
    </Form>
    );

        form.SetValidationMessages(nameof(_model.ValidateField), ["Error message"]);
        cut.Find(".ant-form-item-explain-error").Text().Trim().Should().Be("Error message");

        form.SetValidationMessages(nameof(_model.ValidateField), ["New Error message"]);
        cut.Find(".ant-form-item-explain-error").Text().Trim().Should().Be("New Error message");
    }
}
